package com.wrial.seckill.error;
/*
 * @Author  Wrial
 * @Date Created in 10:07 2020/4/4
 * @Description  自定义异常码，供传入CustomizeErrorCode
 */

public enum CustomizeErrorCode implements CommonError {
    //通用错误类型10001
    PARAMETER_VALIDATION_ERROR(10001,"参数不合法"),
    UNKNOWN_ERROR(10002,"未知错误"),

    //20000开头为用户信息相关错误定义
    USER_NOT_EXIST(20001,"用户不存在"),
    USER_LOGIN_FAIL(20002,"用户手机号或密码不正确"),
    USER_NOT_LOGIN(20003,"用户还未登陆"),

    //30000开头为交易信息错误定义
    STOCK_NOT_ENOUGH(30001,"库存不足");

    private Integer errCode;
    private String errMsg;

    CustomizeErrorCode(Integer errCode, String errMsg){
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    @Override
    public Integer getCode() {
        return this.errCode;
    }

    @Override
    public String getMessage() {
        return this.errMsg;
    }

    @Override
    public CommonError setMessage(String message) {
        this.errMsg = message;
        return this;
    }
}
